<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定位</title>
    <style>
        .con{
            width: 400px;
            height: 400px;
            border: 1px solid #000;
            margin: 100px auto 0;
            position: relative;
        }
        .con div, .box4{
            width: 200px;
            height: 100px;
            margin: 20px;
            background-color: gold;
            line-height: 100px;
            text-align: center;
            font-size: 40px;
        }
        .con .box1{
            position: relative;
            left: 50px;
            top: 50px;
            background-color: green;
            z-index: 2;
        }
        .con .box2{
            position: absolute;
            left: 0px;
            top: 0px;
            background-color: red;
            z-index: 1;
        }
        .box4{
            background-color: pink;
            position: fixed;
            right: 0px;
            top: 0px;
        }
    </style>
</head>
<body>
    <div class="con">
        <div class="box1">1</div>
        <div class="box2">2</div>
        <div class="box3">3</div>
    </div>

    <div class="box4">4</div>
</body>
</html>